import sys
import requests
import dns.resolver
import time
import webbrowser
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, 
                            QHBoxLayout, QLineEdit, QPushButton, QTextEdit, 
                            QLabel, QProgressBar, QFrame, QTableWidget, QTableWidgetItem,
                            QHeaderView)
from PyQt5.QtCore import Qt, QThread, pyqtSignal
from PyQt5.QtGui import QFont, QPalette, QColor
import warnings
import threading
import re
from concurrent.futures import ThreadPoolExecutor, as_completed

warnings.filterwarnings("ignore")

class ScannerThread(QThread):
    """ئايرىم لىنىيە ئارقىلىق تەكشۈرۈش"""
    update_progress = pyqtSignal(str)
    scan_complete = pyqtSignal(list)
    progress_update = pyqtSignal(int)

    def __init__(self, domain):
        super().__init__()
        self.domain = domain
        self.active_subdomains = []
        self.is_running = True  # تەكشۈرۈش ھالىتى

    def load_subdomains(self, filename="subdomains.txt"):
        try:
            with open(filename, 'r') as file:
                return [line.strip() for line in file if line.strip()]
        except FileNotFoundError:
            return []

    def is_domain_active(self, domain):
        """تور نامىنىڭ ئاكتىپلىقىنى تەكشۈرۈش"""
        try:
            dns.resolver.resolve(domain, 'A')
            try:
                response = requests.get(f"http://{domain}", timeout=5)
                if response.status_code == 200:
                    info = self.get_domain_info(domain, "http")
                    return True, response.status_code, "http", info
            except requests.RequestException:
                try:
                    response = requests.get(f"https://{domain}", timeout=5)
                    if response.status_code == 200:
                        info = self.get_domain_info(domain, "https")
                        return True, response.status_code, "https", info
                except requests.RequestException:
                    pass
            return True, response.status_code if 'response' in locals() else None, "http", None
        except Exception:
            return False, None, None, None

    def check_subdomain(self, subdomain):
        """بىر ئىككىنچى دەرىجىلىك تور نامىنى تەكشۈرۈش"""
        full_domain = f"{subdomain}.{self.domain}"
        self.update_progress.emit(f"تەكشۈرۈۋاتىدۇ: {full_domain}")
        
        is_active, status_code, protocol, info = self.is_domain_active(full_domain)
        
        if is_active:
            self.active_subdomains.append({
                'domain': full_domain,
                'status': status_code,
                'protocol': protocol,
                'info': info
            })

    def stop(self):
        """تەكشۈرۈشنى توختىتىش"""
        self.is_running = False

    def run(self):
        subdomains = self.load_subdomains()
        total = len(subdomains)
        completed = 0
        
        # پاراللېل تەكشۈرۈش سانى
        max_workers = 50  # تەكشۈرۈش لىنىيە سانىنى كۆپەيتتۇق
        
        with ThreadPoolExecutor(max_workers=max_workers) as executor:
            # بارلىق تەكشۈرۈش ۋەزىپىلىرىنى قوشۇش
            future_to_subdomain = {
                executor.submit(self.check_subdomain_async, subdomain): subdomain 
                for subdomain in subdomains
            }
            
            # نەتىجىلەرنى كۈتۈش
            for future in as_completed(future_to_subdomain):
                if not self.is_running:
                    executor.shutdown(wait=False)
                    self.update_progress.emit("تەكشۈرۈش توختىتىلدى")
                    return
                
                completed += 1
                progress = min(100, int(completed / total * 100))
                self.progress_update.emit(progress)
        
        if self.is_running:
            self.scan_complete.emit(self.active_subdomains)

    def check_subdomain_async(self, subdomain):
        """ئايرىم لىنىيەدە تەكشۈرۈش"""
        if not self.is_running:
            return
            
        full_domain = f"{subdomain}.{self.domain}"
        self.update_progress.emit(f"تەكشۈرۈۋاتىدۇ: {full_domain}")
        
        is_active, status_code, protocol, info = self.is_domain_active(full_domain)
        
        if is_active:
            self.active_subdomains.append({
                'domain': full_domain,
                'status': status_code,
                'protocol': protocol,
                'info': info
            })

    def get_domain_info(self, domain, protocol):
        """تور نامىنىڭ قوشۇمچە ئۇچۇرلىرىنى ئېلىش"""
        try:
            # IP ئادرېسى
            ip_addresses = []
            for rdata in dns.resolver.resolve(domain, 'A'):
                ip_addresses.append(str(rdata))
            
            # تور بېكەت ئۇچۇرلىرى
            url = f"{protocol}://{domain}"
            start_time = time.time()
            response = requests.get(url, timeout=5, verify=False)
            response_time = round((time.time() - start_time) * 1000)  # مىللىسېكۇنت
            
            # SSL گۇۋاھنامە ئۇچۇرلىرى
            ssl_info = None
            if protocol == "https":
                import ssl
                import socket
                context = ssl.create_default_context()
                with context.wrap_socket(socket.socket(), server_hostname=domain) as s:
                    s.connect((domain, 443))
                    cert = s.getpeercert()
                    ssl_info = {
                        'issuer': dict(x[0] for x in cert['issuer']),
                        'expires': cert['notAfter'],
                        'subject': dict(x[0] for x in cert['subject'])
                    }
            
            return {
                'ip_addresses': ip_addresses,
                'response_time': response_time,
                'server': response.headers.get('Server'),
                'title': self.get_page_title(response.text),
                'ssl_info': ssl_info
            }
        except Exception as e:
            return {
                'ip_addresses': [],
                'response_time': None,
                'server': None,
                'title': None,
                'ssl_info': None
            }

    def get_page_title(self, html):
        """HTML دىن ماۋزۇنى ئېلىش"""
        try:
            # ماۋزۇنى ئىزدەش
            title_match = re.search('<title[^>]*>(.*?)</title>', html, re.IGNORECASE | re.DOTALL)
            if not title_match:
                return None
            
            title = title_match.group(1).strip()
            
            # HTML تاگلارنى چىقىرىۋېتىش
            title = re.sub('<[^<]+?>', '', title)
            
            try:
                # ئاۋۋال UTF-8 بىلەن سىناپ باقايلى
                title = title.encode('latin1').decode('utf-8')
            except:
                try:
                    # UTF-8 بولمىسا GBK بىلەن سىناپ باقايلى
                    title = title.encode('latin1').decode('gbk')
                except:
                    try:
                        # GBK بولمىسا GB2312 بىلەن سىناپ باقايلى
                        title = title.encode('latin1').decode('gb2312')
                    except:
                        # ھېچقايسى بولىسا ئەسلى ھالىتىدە قايتۇرايلى
                        pass
            
            # بوشلۇقلارنى تازىلاش
            title = ' '.join(title.split())
            return title if title else None
        except:
            return None

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("ئىككىنچى دەرىجىلىك تور نامى تەكشۈرگۈچ")
        self.setMinimumSize(1000, 600)
        self.setLayoutDirection(Qt.RightToLeft)
        
        # ئۇسلۇب قوشۇش
        self.setStyleSheet("""
            QMainWindow {
                background-color: #f0f2f5;
            }
            QFrame {
                background: #ffffff;
                border-radius: 15px;
                border: 1px solid #e1e4e8;
            }
            QLineEdit {
                padding: 10px;
                background: #ffffff;
                border: 1px solid #e1e4e8;
                border-radius: 8px;
                font-size: 14px;
                color: #333;
            }
            QLineEdit:focus {
                border: 1px solid #0d6efd;
                background: #ffffff;
            }
            QPushButton {
                padding: 10px 20px;
                background: #0d6efd;
                color: white;
                border: none;
                border-radius: 8px;
                font-size: 14px;
                min-width: 100px;
            }
            QPushButton:hover {
                background: #0b5ed7;
            }
            QPushButton:pressed {
                background: #0a58ca;
            }
            QPushButton:disabled {
                background: #ccc;
            }
            QTableWidget {
                background: #ffffff;
                border: 1px solid #e1e4e8;
                border-radius: 10px;
                gridline-color: #e0e0e0;
                color: #333333;
            }
            QTableWidget::item {
                padding: 8px;
                border-bottom: 1px solid #f0f0f0;
                color: #333333;
            }
            QTableWidget::item:selected {
                background: #e3f2fd;
                color: #333333;
            }
            QHeaderView::section {
                background: #f8f9fa;
                padding: 10px;
                border: none;
                border-bottom: 2px solid #e0e0e0;
                font-weight: bold;
                color: #444;
            }
            QProgressBar {
                border: 1px solid #e1e4e8;
                border-radius: 8px;
                text-align: center;
                height: 25px;
                background: #ffffff;
            }
            QProgressBar::chunk {
                background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
                                          stop:0 #28a745,
                                          stop:1 #2ecc71);
                border-radius: 7px;
            }
            QLabel {
                font-size: 14px;
                color: #333;
                font-weight: 500;
            }
            /* توختىتىش كۇنۇپكىسى */
            #stop_button {
                background: #dc3545;
            }
            #stop_button:hover {
                background: #c82333;
            }
            #stop_button:pressed {
                background: #bd2130;
            }
        """)
        
        central_widget = QWidget()
        self.setCentralWidget(central_widget)
        layout = QVBoxLayout(central_widget)
        layout.setContentsMargins(20, 20, 20, 20)
        layout.setSpacing(15)
        
        # كىرگۈزۈش رامكىسى
        input_frame = QFrame()
        input_layout = QVBoxLayout(input_frame)
        input_layout.setContentsMargins(15, 15, 15, 15)
        
        domain_label = QLabel("تەكشۈرمەكچى بولغان تورنامىنى كىرگۈزۈڭ:")
        domain_label.setStyleSheet("""
            QLabel {
                font-size: 14px;
                color: #333;
                font-weight: 500;
                border: none;  /* سىزىقنى يوقىتىش */
                background: transparent;  /* تەگلىكنى سۈزۈك قىلىش */
            }
        """)
        input_layout.addWidget(domain_label)
        
        input_field_layout = QHBoxLayout()
        self.domain_input = QLineEdit()
        self.domain_input.setPlaceholderText("مەسىلەن: baidu.com")
        self.scan_button = QPushButton("تەكشۈرۈش")
        self.stop_button = QPushButton("توختىتىش")
        self.stop_button.setEnabled(False)
        self.stop_button.setStyleSheet("""
            QPushButton {
                background-color: #dc3545;
            }
            QPushButton:hover {
                background-color: #c82333;
            }
            QPushButton:disabled {
                background-color: #ccc;
            }
        """)
        
        input_field_layout.addWidget(self.stop_button)
        input_field_layout.addWidget(self.scan_button)
        input_field_layout.addWidget(self.domain_input)
        input_layout.addLayout(input_field_layout)
        
        layout.addWidget(input_frame)
        
        # نەتىجە جەدۋىلى
        result_frame = QFrame()
        result_layout = QVBoxLayout(result_frame)
        result_layout.setContentsMargins(15, 15, 15, 15)
        
        result_label = QLabel("نەتىجە:")
        result_label.setStyleSheet("""
            QLabel {
                font-size: 14px;
                color: #333;
                font-weight: 500;
                border: none;
                background: transparent;
                padding: 0;
                margin: 0;
            }
        """)
        result_layout.addWidget(result_label)
        
        # جەدۋەل
        self.result_table = QTableWidget()
        self.result_table.setColumnCount(8)
        self.result_table.setHorizontalHeaderLabels([
            "تور نامى", "ھالىتى", "پروتوكول", "IP ئادرېسى", 
            "جاۋاب ۋاقتى", "سېرۋېر", "ماۋزۇ", "مەشغۇلات"
        ])
        
        # ستون كەڭلىكىنى تەڭشەش
        self.result_table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)  # تور نامى
        self.result_table.horizontalHeader().setSectionResizeMode(3, QHeaderView.Stretch)  # IP
        self.result_table.horizontalHeader().setSectionResizeMode(6, QHeaderView.Stretch)  # ماۋزۇ
        
        # باشقا ستونلارنىڭ كەڭلىكىن بېكىتىش
        self.result_table.setColumnWidth(1, 80)   # ھالىتى
        self.result_table.setColumnWidth(2, 80)   # پروتوكول
        self.result_table.setColumnWidth(4, 100)  # جاۋاب ۋاقتى
        self.result_table.setColumnWidth(5, 100)  # سېرۋېر
        self.result_table.setColumnWidth(7, 100)  # مەشغۇلات
        
        # جەدۋەل ئۇسلۇبى
        self.result_table.setAlternatingRowColors(True)  # قۇرلارنى ئالمىشىپ رەڭلەش
        self.result_table.setStyleSheet("""
            QTableWidget {
                alternate-background-color: #f8f9fa;
            }
            QTableWidget::item:selected {
                background-color: #e3f2fd;
            }
        """)
        
        result_layout.addWidget(self.result_table)
        layout.addWidget(result_frame)
        
        # ئىلگىرىلەش رامكىسى
        progress_frame = QFrame()
        progress_frame.setMaximumHeight(80)
        progress_layout = QHBoxLayout(progress_frame)
        progress_layout.setContentsMargins(15, 10, 15, 10)

        self.status_label = QLabel("تەييار")
        self.status_label.setStyleSheet("""
            QLabel {
                font-size: 14px;
                color: #333;
                font-weight: 500;
                border: none;
                background: transparent;
                padding: 0;
                margin: 0;
            }
        """)

        self.progress_bar = QProgressBar()
        self.progress_bar.setTextVisible(True)

        progress_layout.addWidget(self.status_label)
        progress_layout.addWidget(self.progress_bar)

        layout.addWidget(progress_frame)
        
        # ساقلاش كۇنۇپكىلىرى رامكىسى
        self.save_frame = QFrame()
        self.save_frame.setVisible(False)  # دەسلەپتە يوشۇرۇن
        save_layout = QHBoxLayout(self.save_frame)
        save_layout.setContentsMargins(15, 5, 15, 5)  # گىرۋەكنى كىچىكلەتتۇق
        save_layout.setSpacing(10)  # كۇنۇپكىلار ئارىلىقىنى كىچىكلەتتۇق

        # ساقلاش كۇنۇپكىلىرى
        buttons_data = [
            ("Excel", "excel"), ("HTML", "html"), 
            ("JSON", "json"), ("TXT", "txt")
        ]

        save_button_style = """
            QPushButton {
                background-color: #198754;
                color: white;
                border: none;
                border-radius: 4px;
                padding: 5px 10px;
                font-size: 13px;
                min-width: 70px;
            }
            QPushButton:hover {
                background-color: #157347;
            }
            QPushButton:pressed {
                background-color: #146c43;
            }
        """

        # كۇنۇپكىلارنى قۇرۇش
        for text, format_type in buttons_data:
            button = QPushButton(f"{text} فورماتىدا ساقلاش")
            button.setStyleSheet(save_button_style)
            button.clicked.connect(lambda checked, f=format_type: self.save_results(f))
            save_layout.addWidget(button)

        layout.addWidget(self.save_frame)
        
        # سىگناللارنى باغلاش
        self.scan_button.clicked.connect(self.start_scan)
        self.stop_button.clicked.connect(self.stop_scan)
        self.scanner_thread = None

    def validate_domain(self, domain):
        pattern = r'^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$'
        if re.match(pattern, domain):
            return True
        return False

    def start_scan(self):
        domain = self.domain_input.text().strip()
        if not domain:
            self.status_label.setText("! تور نامىنى كىرگۈزۈڭ")
            return
        
        if not self.validate_domain(domain):
            self.status_label.setText("! تور نامى فورماتى توغرا ئەمەس")
            return
        
        self.scan_button.setEnabled(False)
        self.stop_button.setEnabled(True)
        self.result_table.setRowCount(0)
        self.progress_bar.setValue(0)
        self.status_label.setText("...تەكشۈرۈش باشلاندى")
        
        self.scanner_thread = ScannerThread(domain)
        self.scanner_thread.update_progress.connect(self.update_status)
        self.scanner_thread.scan_complete.connect(self.show_results)
        self.scanner_thread.progress_update.connect(self.progress_bar.setValue)
        self.scanner_thread.start()
        self.save_frame.setVisible(False)

    def stop_scan(self):
        """تەكشۈرۈشنى توختىتىش"""
        if self.scanner_thread and self.scanner_thread.isRunning():
            self.scanner_thread.stop()
            self.stop_button.setEnabled(False)
            self.scan_button.setEnabled(True)
            self.status_label.setText("تەكشۈرۈش توختىتىلدى")

    def update_status(self, message):
        """ھالەت ئۇچۇرىنى يېڭىلاش"""
        # تەكشۈرۈۋاتقن تور نامىنى كۆرسىتىش
        if "تەكشۈرۈۋاتىدۇ" in message:
            domain = message.split(": ")[1]  # تور نامىنى ئايرىۋالىمىز
            self.status_label.setText(f"تەكشۈرۈۋاتىدۇ: {domain}")
        # تاماملىنىش ئۇچۇرى
        elif "تامام" in message or "توختىتىلدى" in message:
            self.status_label.setText(message)
        # كىرگۈزۈش خاتالىقى
        elif "كىرگۈزۈڭ" in message or "فورمات" in message:
            self.status_label.setText(message)

    def show_results(self, results):
        self.scan_button.setEnabled(True)
        self.stop_button.setEnabled(False)
        self.status_label.setText("تامام")
        
        self.result_table.setRowCount(len(results))
        
        for row, result in enumerate(results):
            # تور نامى
            domain_item = QTableWidgetItem(result['domain'])
            domain_item.setTextAlignment(Qt.AlignCenter | Qt.AlignVCenter)
            self.result_table.setItem(row, 0, domain_item)
            
            # ھالىتى
            status_item = QTableWidgetItem(str(result['status']))
            status_item.setTextAlignment(Qt.AlignCenter)
            self.result_table.setItem(row, 1, status_item)
            
            # پروتوكول
            protocol_item = QTableWidgetItem(result['protocol'])
            protocol_item.setTextAlignment(Qt.AlignCenter)
            self.result_table.setItem(row, 2, protocol_item)
            
            # info مەۋجۇت بولسا
            if result.get('info'):
                # IP ئادرېسى
                ip_addresses = result['info'].get('ip_addresses', [])
                ip_addresses_item = QTableWidgetItem(', '.join(ip_addresses) if ip_addresses else '')
                ip_addresses_item.setTextAlignment(Qt.AlignCenter)
                self.result_table.setItem(row, 3, ip_addresses_item)
                
                # جاۋاب ۋاقتى
                response_time = result['info'].get('response_time')
                response_time_item = QTableWidgetItem(str(response_time) if response_time else '')
                response_time_item.setTextAlignment(Qt.AlignCenter)
                self.result_table.setItem(row, 4, response_time_item)
                
                # سېرۋېر
                server = result['info'].get('server')
                server_item = QTableWidgetItem(server if server else '')
                server_item.setTextAlignment(Qt.AlignCenter)
                self.result_table.setItem(row, 5, server_item)
                
                # ماۋزۇ
                title = result['info'].get('title')
                title_item = QTableWidgetItem(title if title else '')
                title_item.setTextAlignment(Qt.AlignCenter)
                self.result_table.setItem(row, 6, title_item)
            else:
                # info يوق بولسا قۇرۇق قالدۇرۇش
                for col in range(3, 7):
                    empty_item = QTableWidgetItem('')
                    empty_item.setTextAlignment(Qt.AlignCenter)
                    self.result_table.setItem(row, col, empty_item)
            
            # زىيارەت قىسمى
            link_widget = QWidget()
            link_layout = QHBoxLayout(link_widget)
            link_layout.setContentsMargins(0, 0, 0, 0)
            link_layout.setSpacing(0)

            # ھەر بىر ئۇلانما ئۈچۈن ئايرىم QPushButton قۇرۇش
            link_button = QPushButton("ئېچىش")
            link_button.setCursor(Qt.PointingHandCursor)
            link_button.setStyleSheet("""
                QPushButton {
                    color: #0d6efd;
                    font-size: 13px;
                    border: none;
                    background: transparent;
                    padding: 0;
                    margin: 0;
                    text-align: center;
                }
                QPushButton:hover {
                    color: #0a58ca;
                    text-decoration: underline;
                }
            """)

            # URL نى button نىڭ property سىگە ساقلاش
            url = f"{result['protocol']}://{result['domain']}"
            link_button.clicked.connect(lambda checked, u=url: webbrowser.open(u))

            link_layout.addWidget(link_button)
            link_layout.setAlignment(Qt.AlignCenter)

            self.result_table.setCellWidget(row, 7, link_widget)
        
        # جەدۋەل قۇرىنىڭ ئېگىزلىكىنى تەڭشەش
        self.result_table.verticalHeader().setDefaultSectionSize(45)

        # نەتىجە كۆرسىتىلگەندىن كېيىن ساقلاش كۇنۇپكىلىرىنى كۆرسىتىش
        self.save_frame.setVisible(True)

    def save_results(self, format_type):
        """نەتىجىنى ساقلاش"""
        try:
            if format_type == 'excel':
                import pandas as pd
                # نەتىجىنى DataFrame غا ئايلاندۇرۇش
                data = []
                for row in range(self.result_table.rowCount()):
                    row_data = {}
                    for col in range(self.result_table.columnCount()-1):  # مەشغۇلات ستونىنى ئالمايمىز
                        header = self.result_table.horizontalHeaderItem(col).text()
                        item = self.result_table.item(row, col)
                        row_data[header] = item.text() if item else ''
                    data.append(row_data)
                
                df = pd.DataFrame(data)
                df.to_excel('scan_results.xlsx', index=False)
                self.status_label.setText("نەتىجە Excel فورماتىدا ساقلاندى: scan_results.xlsx")

            elif format_type == 'html':
                html_content = """
                <html>
                <head>
                    <meta charset="utf-8">
                    <style>
                        table { border-collapse: collapse; width: 100%; }
                        th, td { border: 1px solid #ddd; padding: 8px; text-align: center; }
                        tr:nth-child(even) { background-color: #f2f2f2; }
                        th { background-color: #4CAF50; color: white; }
                    </style>
                </head>
                <body>
                <table>
                """
                # جەدۋەل باش قۇرى
                html_content += "<tr>"
                for col in range(self.result_table.columnCount()-1):
                    header = self.result_table.horizontalHeaderItem(col).text()
                    html_content += f"<th>{header}</th>"
                html_content += "</tr>"
                
                # جەدۋەل مەزمۇنى
                for row in range(self.result_table.rowCount()):
                    html_content += "<tr>"
                    for col in range(self.result_table.columnCount()-1):
                        item = self.result_table.item(row, col)
                        html_content += f"<td>{item.text() if item else ''}</td>"
                    html_content += "</tr>"
                
                html_content += "</table></body></html>"
                
                with open('scan_results.html', 'w', encoding='utf-8') as f:
                    f.write(html_content)
                self.status_label.setText("نەتىجە HTML فورماتىدا ساقلاندى: scan_results.html")

            elif format_type == 'json':
                import json
                data = []
                for row in range(self.result_table.rowCount()):
                    row_data = {}
                    for col in range(self.result_table.columnCount()-1):
                        header = self.result_table.horizontalHeaderItem(col).text()
                        item = self.result_table.item(row, col)
                        row_data[header] = item.text() if item else ''
                    data.append(row_data)
                
                with open('scan_results.json', 'w', encoding='utf-8') as f:
                    json.dump(data, f, ensure_ascii=False, indent=4)
                self.status_label.setText("نەتىجە JSON فورماتىدا ساقلاندى: scan_results.json")

            elif format_type == 'txt':
                with open('scan_results.txt', 'w', encoding='utf-8') as f:
                    # باش قۇر
                    headers = []
                    for col in range(self.result_table.columnCount()-1):
                        headers.append(self.result_table.horizontalHeaderItem(col).text())
                    f.write('\t'.join(headers) + '\n')
                    
                    # مەزمۇن
                    for row in range(self.result_table.rowCount()):
                        row_data = []
                        for col in range(self.result_table.columnCount()-1):
                            item = self.result_table.item(row, col)
                            row_data.append(item.text() if item else '')
                        f.write('\t'.join(row_data) + '\n')
                self.status_label.setText("نەتىجە TXT فورماتىدا ساقلاندى: scan_results.txt")

        except Exception as e:
            self.status_label.setText(f"نەتىجە ساقلاشتا خاتالىق كۆرۈلدى: {str(e)}")

if __name__ == '__main__':
    app = QApplication(sys.argv)
    
    # فونت ەڭشەش
    font = QFont("UKIJ Ekran")
    font.setPointSize(10)
    app.setFont(font)
    
    window = MainWindow()
    window.show()
    sys.exit(app.exec_()) 